JavaScript

A5.u.array.seriesfrom Method

Syntax

A5.u.array.series.from(array1,...arrayN,settings)

Arguments

array1string

N (array:required) - The series arrays to convert to a single array of objects.

settingsobject

The settings for the conversion.

namesarray

A mapping to convert the values from each series passed in to properties in the array objects.

blankarray

A mapping for missing values for each series.

arrayarray

The resulting array of object.

Description

Convert an arbitrary number of series arrays into an array of objects.

Discussion

The A5.u.array.series.from method takes an arbitrary number of series arrays and converts them into a single array of objects. The name of each property in each array item object is controlled by the "names" property in the settings object. Defaults for missing values can be defined with the "blank" property.

Example

var arr = A5.u.array.series.from(["Bob","Fred"],["Thomas","Mills","Baker"],[45,23],{
	names: ['fn','ln','age'],
	blank: ['[none]','[none]','[unknown]']
});
// arr = [
//	{"fn":"Bob","ln":"Thomas","age":45},
//	{"fn":"Fred","ln":"Mills","age":23},
//	{"fn":"[none]","ln":"Baker","age":"[unknown]"}
// ]